/********************************************************************
	File		: Texture.h
	Created		: 2011-2-25	22:45
	Author		: Wjl

	Desc		: This file is part of omiga 2d engine.
*********************************************************************/

#ifndef Texture_H__
#define Texture_H__

#include <string>
#include "OpenglHeader.h"

namespace Vis
{
	class Texture
	{
	public:

		Texture();
		~Texture();

		unsigned int	GetOpenglTextureId() const { return m_uiId; }
		
		void			LoadTGAFile(const std::string& _fileName);
		
		void			LoadPNGFile(const std::string& _fileName);

	private:

		unsigned int	m_uiId;
	
	private:

		typedef struct
		{
			unsigned int  id; // open gl Texture id 
			unsigned int  width;           
			unsigned int  height;          

			unsigned int  format;          /* RVB, RVBA, Luminance, Luminance Alpha */
			int			  internalFormat;  /* texel component */

			char*         texels;         /* datas */

		} tga_texture_t;

		/* tga header */
		typedef struct
		{
			char id_lenght;          /* size of image id */
			char colormap_type;      /* 1 is has a colormap */
			char image_type;         /* compression type */

			signed short	cm_first_entry;       /* colormap origin */
			signed short	cm_length;            /* colormap length */
			char		    cm_size;            /* colormap size */

			signed short	x_origin;             /* bottom left x coord origin */
			signed short	y_origin;             /* bottom left y coord origin */

			signed short	width;                /* picture width (in pixels) */
			signed short	height;               /* picture height (in pixels) */

			char pixel_depth;        /* bits per pixel: 8, 16, 24 or 32 */
			char image_descriptor;   /* 24 bits = 0x00; 32 bits = 0x80 */

		} tga_header_t;

	};
}

#endif // Texture_H__